//
//  ShoppingImageScrollView.m
//  DA_V
//
//  Created by 中亿世联前台 on 15/4/22.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "ShoppingImageScrollView.h"
#import "ShoppingImageView.h"
#import "UIImageView+WebCache.h"
#import "InterFace.h"
#import "CarModel.h"
#import "MyListModel.h"
@implementation ShoppingImageScrollView


- (instancetype) initWithFrame:(CGRect)frame data:(NSArray *)data{

    self = [super initWithFrame:frame];
    if (self) {
        
        
        for (int i = 0; i < [data count]; i++) {
              ShoppingImageView *shoppingImageView = [[[NSBundle mainBundle] loadNibNamed:@"Shopping_Cart_Xib" owner:self options:nil] objectAtIndex:4];
          
            if ( [[data[i] class] isSubclassOfClass:[CarModel class]]) {
                CarModel *carModel = data[i];
                NSURL *url = [NSURL URLWithString:carModel.ThumbPath];
                shoppingImageView.shoppingNumBer.text = [NSString stringWithFormat:@"X%@",carModel.Number];
                     shoppingImageView.zeKouJia.text = [NSString stringWithFormat:@"¥%.1f",carModel.MarketAmount.floatValue];
                [shoppingImageView.shoppingImag sd_setImageWithURL:url placeholderImage:nil];
                shoppingImageView.shoppingName.text = carModel.ProductName;
            }
            if ( [[data[i] class] isSubclassOfClass:[MyListModel class]]) {
                MyListModel *carModel = data[i];
                NSURL *url = [NSURL URLWithString:carModel.ThumbPath];
                shoppingImageView.shoppingNumBer.text = [NSString stringWithFormat:@"X%@",carModel.BuyAmount];
                  shoppingImageView.zeKouJia.text = [NSString stringWithFormat:@"¥%.1f",carModel.DiscountPriceAmount.floatValue];
                [shoppingImageView.shoppingImag sd_setImageWithURL:url placeholderImage:nil];
                shoppingImageView.shoppingName.text = carModel.ProductName;
            }
            
                  shoppingImageView.frame = CGRectMake(i * SCREEN_WIDTH / 3.0 + 10 , 10, (SCREEN_WIDTH-50) / 3.0, (SCREEN_WIDTH-50) / 3.0+30);
            
            [self addSubview:shoppingImageView];
        }
    }
    return self;
}

+ (instancetype) soppingImageScrollViewWithFrame:(CGRect)frame data:(NSArray *)data{

    ShoppingImageScrollView *shoppingScrollView = [[ShoppingImageScrollView alloc] initWithFrame:frame data:data];
    return shoppingScrollView;
    
}


@end
